import axios from '@/plugins/axios'

// 账号列表
export async function candidateList (params) {
  try {
    let res = await axios.post(`/jobboard/jobboardcandidates/candidate/candidateList`, params)
    return res.data
  } catch (err) {
    console.log(err)
    return err.response.data
  }
}
// 禁用状态修改
export async function changeAccountStatus (params) {
  try {
    let res = await axios.get(`/jobboard/jobboardcandidates/candidate/changeAccountStatus?status=${params.status}&userId=${params.userId}`)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 删除候选人账号
export async function deleteAccount (params) {
  try {
    let res = await axios.post(`/jobboard/jobboardcandidates/candidate/deleteAccount`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 批量禁用/启用候选人账号
export async function changeAccountStatusBatch (params) {
  try {
    let res = await axios.post(`/jobboard/jobboardcandidates/candidate/changeAccountStatusBatch`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 创建账号
export async function createAccount (params) { // 编辑、创建账号
  try {
    // let res = await axios.post(`/user/create`, params)
    let res = await axios({
      method: 'post',
      url: '/user/create',
      data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}
// 编辑账号
export async function editAccount (params) { // 编辑、创建账号
  try {
    let res = await axios.post(`/user/create`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 修改状态
export async function changeStatusAccount (params) { // 修改账号状态 *******
  try {
    let res = await axios.post(`/user/changeStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 修改状态
export async function changeAuditStatus (params) { // 修改会员状态 *******
  try {
    let res = await axios.post(`/user/changeAuditStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 账号列表
export async function findAllAccount (params) { // 账号列表 *******
  try {
    let res = await axios.post(`/user/findAll`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 账号列表
export async function countAccount (role) { // 账号状态 ******
  try {
    let res = await axios.get(`/user/statusList?role=${role}`)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 账号列表
export async function approve (params) {
  try {
    let res = await axios.post(`/jobboard/employers/account/approve`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 账号列表
export async function cancelToJoin (params) {
  try {
    let res = await axios.post(`/jobboard/employers/account/cancelToJoin`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 账号列表
export async function passToTask (params) {
  try {
    let res = await axios.post(`/jobboard/employers/account/passToTask`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 负责人列表
export async function findAcctList (params) {
  try {
    let res = await axios.post(`/jobboard/employers/account/findList`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 负责人列表
export async function recentlySelected (params) {
  try {
    let res = await axios.post(`/jobboard/employers/account/recentlySelected`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 负责人列表
export async function permissionList (params) {
  try {
    let res = await axios.post(`/jobboard/employers/permission/list`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 获取配置后的所有省市
export async function getAvailableCityList (data) {
  try {
    let res = await axios.post('/jobboard/positions/city/provinceCityList', data)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 职位优先级获取
export async function getCityCitys (params) {
  try {
    let res = await axios.post(`/jobboard/positions/city/provinceCityList`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 职位优先级获取
export async function findApplicationCustomInfo (params) {
  try {
    let res = await axios.post(`/jobboard/settings/company/findApplicationCustomInfo`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 创建课程
export async function createCourse (params) {
  try {
    let res = await axios.post(`/campaign/create`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 课程列表
export async function findAllCourse (params) {
  try {
    // let res = await axios.post(`/campaign/findAll`, params)
    let res = await axios({
      method: 'post',
      url: '/campaign/findAll',
      data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}
// 课程详情
export async function getCourseDetail (params) {
  try {
    // let res = await axios.get(`/campaign/campaignInfoById?id=${params.id}`)
    let res = await axios({
      method: 'get',
      url: `/campaign/campaignInfoById?id=${params.id}`,
      // data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}
// 课程取消/结束招募
export async function changeCourseStatus (params) {
  try {
    let res = await axios.post(`/campaign/changeStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 课程审核
export async function changeCourseAuditStatus (params) {
  try {
    let res = await axios.post(`/campaign/changeAuditStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}
// 课程类别数量
export async function countCourse (params) {
  try {
    let res = await axios.post(`/campaign/statusList`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 课程报名
export async function signUp (params) {
  try {
    let res = await axios.post(`/campaign/signUp`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 课程退课
export async function cancelSignUp (params) {
  try {
    let res = await axios.post(`/campaign/cancelSignUp`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 添加 照片 视频
export async function addExpansion (params) {
  try {
    let res = await axios.post(`/campaign/addExpansion`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 添加 文件
export async function addExpansionFile (params) {
  try {
    let res = await axios({
      method: 'post',
      url: '/campaign/addExpansionFile',
      data: params,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 加积分
export async function addScore (params) {
  try {
    let res = await axios.post(`/user/addScore`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 活动 创建--------------
export async function createActivity (params) {
  try {
    let res = await axios.post(`/systemNews/create`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 活动 查询
export async function findAllActivity (params) {
  try {
    // let res = await axios.post(`/systemNews/findAll`, params)
    let res = await axios({
      method: 'post',
      url: '/systemNews/findAll',
      data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 活动 改状态
export async function changeActivityStatus (params) {
  try {
    let res = await axios.post(`/systemNews/changeStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 活动 状态统计
export async function countActivity (params) {
  try {
    let res = await axios.get(`/systemNews/statusList`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 活动 根据id查数据
export async function activityDetail (params) {
  try {
    // let res = await axios.get(`/systemNews/newsInfoById?id=` + params.id)
    let res = await axios({
      method: 'get',
      url: `/systemNews/newsInfoById?id=${params.id}`,
      // data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精选照片 创建------------
// export async function createPic (params) {
//   try {
//     let res = await axios.post(`/systemPicture/create`, params)
//     return res.data
//   } catch (error) {
//     return error.data
//   }
// }
export async function createPic (params) {
  try {
    let res = await axios({
      method: 'post',
      url: '/systemPicture/create',
      data: params,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精选照片 查询
export async function findAllPic (params) {
  try {
    // let res = await axios.post(`/systemPicture/findAll`, params)
    let res = await axios({
      method: 'post',
      url: '/systemPicture/findAll',
      data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精选照片 改状态
export async function changePicStatus (params) {
  try {
    let res = await axios.post(`/systemPicture/changeStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精选照片 状态统计
export async function countPic (params) {
  try {
    let res = await axios.get(`/systemPicture/statusList`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精选照片 根据id查数据
export async function picDetail (params) {
  try {
    // let res = await axios.get(`/systemPicture/newsInfoById?id=` + params.id)
    let res = await axios({
      method: 'get',
      url: `/systemPicture/newsInfoById?id=${params.id}`,
      // data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精彩视频 创建----------
export async function createVideo (params) {
  try {
    let res = await axios.post(`/systemVideo/create`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精彩视频 查询
export async function findAllVideo (params) {
  try {
    // let res = await axios.post(`/systemVideo/findAll`, params)
    let res = await axios({
      method: 'post',
      url: '/systemVideo/findAll',
      data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精彩视频 改状态
export async function changeVideoStatus (params) {
  try {
    let res = await axios.post(`/systemVideo/changeStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精彩视频 状态统计
export async function countVideo (params) {
  try {
    let res = await axios.get(`/systemVideo/statusList`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 精彩视频 根据id查数据
export async function videoDetail (params) {
  try {
    // let res = await axios.get(`/systemVideo/newsInfoById?id=` + params.id)
    let res = await axios({
      method: 'get',
      url: `/systemVideo/newsInfoById?id=${params.id}`,
      // data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 关于我们 创建----------
export async function createIntro (params) {
  try {
    let res = await axios.post(`/systemUs/create`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 关于我们 查询
export async function findAllIntro (params) {
  try {
    // let res = await axios.post(`/systemUs/findAll`, params)
    let res = await axios({
      method: 'post',
      url: '/systemUs/findAll',
      data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 关于我们 改状态
export async function changeIntroStatus (params) {
  try {
    let res = await axios.post(`/systemUs/changeStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 关于我们 状态统计
export async function countIntro (params) {
  try {
    let res = await axios.get(`/systemUs/statusList`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 关于我们 根据id查数据
export async function introDetail (params) {
  try {
    // let res = await axios.get(`/systemUs/newsInfoById?id=` + params.id)
    let res = await axios({
      method: 'get',
      url: `/systemUs/newsInfoById?id=${params.id}`,
      // data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 组织机构 创建----------
export async function createInstitution (params) {
  try {
    let res = await axios.post(`/systemOrganization/create`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 组织机构 查询
export async function findAllInstitution (params) {
  try {
    // let res = await axios.post(`/systemOrganization/findAll`, params)
    let res = await axios({
      method: 'post',
      url: '/systemOrganization/findAll',
      data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}

// 组织机构 改状态
export async function changeInstitutionStatus (params) {
  try {
    let res = await axios.post(`/systemOrganization/changeStatus`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 组织机构 状态统计
export async function countInstitution (params) {
  try {
    let res = await axios.get(`/systemOrganization/statusList`, params)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 组织机构 根据id查数据
export async function institutionDetail (params) {
  try {
    let res = await axios.get(`/systemOrganization/newsInfoById?id=` + params.id)
    return res.data
  } catch (error) {
    return error.data
  }
}

// 讯飞
export async function aiPost (params) {
  try {
    // let res = await axios.post(`/ai/xunfei`, params)
    let res = await axios({
      method: 'post',
      url: '/ai/xunfei',
      data: params,
      headers: {
        'unAuthorization': 'Y'
      }
    })
    return res.data
  } catch (error) {
    return error.data
  }
}
